import { lazy, Suspense } from "react";
import { Navigate } from "react-router-dom";
import Loading from "../component/Loading/Loading"
import Datas from "./Datas"
import News from "./News"
import Resident from "./Resident"
import Service from "./Service"
import Signing from "./Signing"
import Statistics from "./Statistics"
import System from "./System"
import Workbench from "./Workbench"



let Login = lazy(() => import("../view/Login/Login"))
let Index = lazy(() => import("../view/Index/Index"))
let NotFound = lazy(() => import("../view/NotFound/NotFound"))
let Register = lazy(() => import("../view/Register/Register"))

let routes = [
    {
        path: "/index",
        element: <Index />,
        children: [
            ...Datas,
            ...News,
            ...Resident,
            ...Service,
            ...Signing,
            ...Statistics,
            ...System,
            ...Workbench,
        ]
    },
    {
        path: "/login",
        element: <Suspense fallback={<Loading/>}><Login /></Suspense>
    },
    {
        path: "/register",
        element: <Suspense fallback={<Loading/>}><Register /></Suspense>
    },
    {
        path: "*",
        element: <Suspense fallback={<Loading/>}><NotFound /></Suspense>//404
    },
    {
        path: "/",
        element: <Navigate to="/index" />//重定项
    }
]
export default routes

